// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

#nullable restore
namespace Elastic.Clients.Elasticsearch.Ml
{
	public sealed partial class ChunkingConfig
	{
		[JsonInclude]
		[JsonPropertyName("mode")]
		public Elastic.Clients.Elasticsearch.Ml.ChunkingMode Mode { get; set; }

		[JsonInclude]
		[JsonPropertyName("time_span")]
		public Elastic.Clients.Elasticsearch.Duration? TimeSpan { get; set; }
	}

	public sealed partial class ChunkingConfigDescriptor : SerializableDescriptorBase<ChunkingConfigDescriptor>
	{
		internal ChunkingConfigDescriptor(Action<ChunkingConfigDescriptor> configure) => configure.Invoke(this);
		public ChunkingConfigDescriptor() : base()
		{
		}

		private Elastic.Clients.Elasticsearch.Ml.ChunkingMode ModeValue { get; set; }

		private Elastic.Clients.Elasticsearch.Duration? TimeSpanValue { get; set; }

		public ChunkingConfigDescriptor Mode(Elastic.Clients.Elasticsearch.Ml.ChunkingMode mode)
		{
			ModeValue = mode;
			return Self;
		}

		public ChunkingConfigDescriptor TimeSpan(Elastic.Clients.Elasticsearch.Duration? timeSpan)
		{
			TimeSpanValue = timeSpan;
			return Self;
		}

		protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
		{
			writer.WriteStartObject();
			writer.WritePropertyName("mode");
			JsonSerializer.Serialize(writer, ModeValue, options);
			if (TimeSpanValue is not null)
			{
				writer.WritePropertyName("time_span");
				JsonSerializer.Serialize(writer, TimeSpanValue, options);
			}

			writer.WriteEndObject();
		}
	}
}